<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>商品编辑</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
  
    <link rel="stylesheet" href="/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="/plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="/css/style.css">
	<script src="/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="/plugins/bootstrap/js/bootstrap.min.js"></script>
    
    <!-- 富文本编辑器 -->
	<link rel="stylesheet" href="/plugins/kindeditor/themes/default/default.css" />
	<script charset="utf-8" src="/plugins/kindeditor/kindeditor-min.js"></script>
	<script charset="utf-8" src="/plugins/kindeditor/lang/zh_CN.js"></script>

	<!--图片上传-->
	<link rel="stylesheet" type="text/css" href="/plugins/bootstrap-fileinput/css/fileinput.min.css">
	<script type="text/javascript" src="/plugins/bootstrap-fileinput/js/fileinput.min.js"></script>
	<script type="text/javascript" src="/plugins/bootstrap-fileinput/js/locales/zh.js"></script>
    
</head>

<body class="hold-transition skin-red sidebar-mini" >
<button onclick="test()" class="btn btn-default" data-dismiss="modal" aria-hidden="true">测试</button>
            <!-- 正文区域 -->
            <section class="content">

                <div class="box-body">

                    <!--tab页-->
                    <div class="nav-tabs-custom">

                        <!--tab头-->
                        <ul class="nav nav-tabs">                       		
                            <li class="active">
                                <a href="#home" data-toggle="tab">商品基本信息</a>                                                        
                            </li>   
                            <li >
                                <a href="#pic_upload" data-toggle="tab">商品图片</a>                                                        
                            </li>    
                            <li >
                                <a href="#customAttribute" data-toggle="tab">扩展属性</a>                                                        
                            </li>     
                            <li >
                                <a href="#spec" data-toggle="tab" >规格</a>                                                        
                            </li>                       
                        </ul>
                        <!--tab头/-->
						
                        <!--tab内容-->
                        <div class="tab-content">

                            <!--表单内容-->
                            <div class="tab-pane active" id="home">
                                <div class="row data-type">                                  
								   <div class="col-md-2 title">商品分类</div>
		                          
		                           	  <div class="col-md-10 data">
		                           	  	<table>
		                           	  		<tr>
		                           	  			<td>
		                           	  				<select onchange="shopItemOne(this.value)" class="form-control" id="shopItemOne" name="category1Id"></select>
		                              			</td>
		                              			<td>
		                           	  				<select onchange="shopItemTow(this.value)" class="form-control select-sm" id="shopItemTow" name="category2Id"></select>
		                              			</td>
		                              			<td>
		                           	  				<select onchange="shopItemThree(this.value)" class="form-control select-sm" id="shopItemThree" name="category3Id"></select>
		                              			</td>
		                              			<td>
		                           	  				模板ID:<a id="typeID" name="typeTemplateId"></a>
		                              			</td>
		                           	  		</tr>
		                           	  	</table>
		                              	
		                              </div>	                              
		                          	  
									
		                           <div class="col-md-2 title">商品名称</div>
		                           <div class="col-md-10 data">
		                               <input type="text" class="form-control" name="goodsName"    placeholder="商品名称">
		                           </div>
		                           
		                           <div class="col-md-2 title">品牌</div>
		                           <div class="col-md-10 data">
		                              <select class="form-control" id="shopType" name="brandId"></select>
		                           </div>
		
								   <div class="col-md-2 title">副标题</div>
		                           <div class="col-md-10 data">
		                               <input type="text" class="form-control" name="caption" placeholder="副标题"/>
		                           </div>
		                           
		                           <div class="col-md-2 title">价格</div>
		                           <div class="col-md-10 data">
		                           	   <div class="input-group">
			                          	   <span class="input-group-addon">¥</span>
			                               <input type="text" class="form-control" name="price"  placeholder="价格"/>
		                           	   </div>
		                           </div>
		                           
		                           <div class="col-md-2 title editer">商品介绍</div>
                                   <div class="col-md-10 data editer">
                                       <textarea name="content" style="width:800px;height:400px;visibility:hidden;" ></textarea>
                                   </div>
		                           
		                           <div class="col-md-2 title rowHeight2x">包装列表</div>
		                           <div class="col-md-10 data rowHeight2x">
		                               
		                           	<textarea rows="4" name="packageList" class="form-control"   placeholder="包装列表"></textarea>
		                           </div>
		                           
		                           <div class="col-md-2 title rowHeight2x">售后服务</div>
		                           <div class="col-md-10 data rowHeight2x">
		                               <textarea rows="4" name="saleService"  class="form-control" placeholder="售后服务"></textarea>
		                           </div>                        
                                  
                                    
                                </div>
                            </div>
                            
                            <!--图片上传-->
                            <div class="tab-pane" id="pic_upload">
                                <div class="row data-type">                                  
								 <!-- 颜色图片 -->
								 <div class="btn-group">
					                 <button type="button" class="btn btn-default" title="新建" data-target="#uploadModal"  data-toggle="modal"  ><i class="fa fa-file-o"></i> 新建</button>
					             </div>
								 
								 <table class="table table-bordered table-striped table-hover dataTable">
					                    <thead>
					                        <tr>
											    <th class="sorting">颜色</th>
											    <th class="sorting">图片</th>
												<th class="sorting">操作</th>
											</tr>
							            </thead>
					                    <tbody id="imgContent">
<!--					                      <tr>					                           -->
<!--									            <td>-->
<!--									            	-->
<!--									            </td>-->
<!--									            <td>-->
<!--									           		<img alt="" src="" width="100px" height="100px">	            	 -->
<!--									            </td>-->
<!--												 <td> <button type="button" class="btn btn-default" title="删除" ><i class="fa fa-trash-o"></i> 删除</button></td> -->
<!--					                      </tr>-->
					                    </tbody>
								 </table> 
								  
                                </div>
                            </div>
                           
                           
                            <!--扩展属性-->
                            <div class="tab-pane" id="customAttribute">
                                <!--<div class="row data-type">
	                                <div>
		                                <div class="col-md-2 title">扩展属性1</div>
				                        <div class="col-md-10 data">
				                              <input name="CAItems1" class="form-control" placeholder="扩展属性1">
				                        </div>
	                                </div>       
									<div>
		                                <div class="col-md-2 title">扩展属性2</div>
				                        <div class="col-md-10 data">
				                              <input name="CAItems1" class="form-control" placeholder="扩展属性2">
				                        </div>
	                                </div>  									
                                </div>-->
                            </div>
                      
                            <!--规格-->
                            <div class="tab-pane" id="spec">
                            	<div class="row data-type">
	                            	<div class="col-md-2 title">是否启用规格</div>
			                        <div id="specIds" class="col-md-10 data">
<!--			                        	<input type="checkbox">-->
			                        </div>
                            	</div>
                            	<p>
                            	
                            	<div>
                            	
	                                <div id="specificationNames" class="row data-type">
	                                
<!--		                                <div name="specificationName">-->
<!--			                                <div class="col-md-2 title">屏幕尺寸</div>-->
<!--					                        <div class="col-md-10 data">-->

<!--					                            <span>-->
<!--					                            	<input  type="checkbox" >4.0					                            				                            	-->
<!--					                            </span>  	-->
<!--												<span>-->
<!--					                            	<input  type="checkbox" >4.5					                            				                            	-->
<!--					                            </span>-->
<!--												<span>-->
<!--					                            	<input  type="checkbox" >5.0					                            				                            	-->
<!--					                            </span>												-->
<!--					                            	-->
<!--					                        </div>-->
<!--		                                </div>   -->
<!--										<div name="specificationName">-->
<!--			                                <div class="col-md-2 title">网络制式</div>-->
<!--					                        <div class="col-md-10 data">-->
<!--					                               -->
<!--					                            <span>-->
<!--					                            	<input  type="checkbox" >2G					                            				                            	-->
<!--					                            </span>  	-->
<!--												<span>-->
<!--					                            	<input  type="checkbox" >3G					                            				                            	-->
<!--					                            </span>-->
<!--												<span>-->
<!--					                            	<input  type="checkbox" >4G					                            				                            	-->
<!--					                            </span>												-->
<!--					                            	-->
<!--					                        </div>-->
<!--		                                </div>  -->
		                                                                                  
	                                </div>
	
	                                
	                                <div class="row data-type">
	                                	 <table id="tables" class="table table-bordered table-striped table-hover dataTable">
						                    <thead>
						                        <tr>					                          
												    <th class="sorting">屏幕尺寸</th>
													<th class="sorting">网络制式</th>
												    <th class="sorting">价格</th>
												    <th class="sorting">库存</th>
												    <th class="sorting">是否启用</th>
												    <th class="sorting">是否默认</th>
											    </tr>
								            </thead>
						                    <tbody>
						                      <tr>					                           
										            <td>
										            	4.0
														<input name="network" type="text">
										            </td>
													<td>
														<input name="memorys" type="text">
										            	3G
										            </td>
										            <td>
										           		<input name="price" class="form-control"  placeholder="价格">
										            </td>
										            <td>
										            	<input name="num" class="form-control" placeholder="库存数量">
										            </td>
										            <td>
										             	<input name="status" type="checkbox" value="0" >
										            </td>
										            <td>
										                <input name="isDefault" type="checkbox" value="0" >
										            </td>
						                      </tr>
											  <tr>					                           
										            <td>
										            	4.0
														<input name="network" type="text">
													</td>
												  <td>
													  <input name="memorys" type="text">
										            	4G
										            </td>
												  <td>
													  <input name="price" class="form-control"  placeholder="价格">
												  </td>
												  <td>
													  <input name="num" class="form-control" placeholder="库存数量">
												  </td>
												  <td>
													  <input name="status" type="checkbox" value="0">
												  </td>
												  <td>
													  <input name="isDefault" type="checkbox" value="0">
												  </td>
						                      </tr>
											  <tr>					                           
													<td>
										            	5.0
														<input name="network" type="text">
													</td>
												  <td>
													  <input name="memorys" type="text">
										            	3G
										            </td>
												  <td>
													  <input name="price" class="form-control"  placeholder="价格">
												  </td>
												  <td>
													  <input name="num" class="form-control" placeholder="库存数量">
												  </td>
												  <td>
													  <input name="status" type="checkbox" value="0">
												  </td>
												  <td>
													  <input name="isDefault" type="checkbox" value="0">
												  </td>
						                      </tr>
											  <tr>					                           
													<td>
										            	5.0
														<input name="network" type="text">
													</td>
												  <td>
													  <input name="memorys" type="text">
										            	4G
										            </td>
												  <td>
													  <input name="price" class="form-control"  placeholder="价格">
												  </td>
												  <td>
													  <input name="num" class="form-control" placeholder="库存数量">
												  </td>
												  <td>
													  <input name="status" type="checkbox" value="0">
												  </td>
												  <td>
													  <input name="isDefault" type="checkbox" value="0">
												  </td>
						                      </tr>
											  
						                    </tbody>
									 	</table>
								
	                                </div>
	                                
	                            </div>
                            </div>
                            
                        </div>
                        <!--tab内容/-->
						<!--表单内容/-->
							 
                    </div>
                 	
                 	
                 	
                 	
                   </div>
                  <div class="btn-toolbar list-toolbar">
				      <button onclick="addGoodsAndDesc()" class="btn btn-primary" ><i class="fa fa-save"></i>保存</button>
				      <button class="btn btn-default" >返回列表</button>
				  </div>
			
            </section>
            
            
<!-- 上传窗口 -->
<div class="modal fade" id="uploadModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog" >
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
			<h3 id="myModalLabel">上传商品图片</h3>
		</div>
		<div class="modal-body">							
			
			<table class="table table-bordered table-striped">
		      	<tr>
		      		<td>颜色</td>
		      		<td><input id="imgColor"  class="form-control" placeholder="颜色" >  </td>
		      	</tr>			    
		      	<tr>
		      		<td>商品图片</td>
		      		<td>
						<table>
							<tr>
								<td>
									<input type="text" name="goodImage">
									<input type="file" id="myFile" name="myFile"><!-- multiple支持多个文件上传 -->
								</td>
							</tr>						
						</table>
		      		</td>
		      	</tr>		      	
			 </table>				
			
		</div>
		<div class="modal-footer">						
			<button onclick="addMigContent()" class="btn btn-success"  data-dismiss="modal" aria-hidden="true">保存</button>
			<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</button>
		</div>
	  </div>
	</div>
</div>

            
            <!-- 正文区域 /-->
<script type="text/javascript">

	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="content"]', {
			allowFileManager : true
		});
	});
	function test() {
		/*获取选中的规格*/
		var txCheck = [];
		$("[name='txCheck']").each(function () {
			var Item = {attributeName:$(this).text()};
			txCheck.push(Item);
		});
		var txCheckNC = [];
		$("[name='sCheck1']:checked").each(function () {
			txCheckNC.push($(this).val());
		});
		var texts = [];
		$("[name='sCheck2']:checked").each(function () {
			texts.push($(this).val());
		});
		var specificationItems = [];
		specificationItems.push({attributeName:txCheck[0].attributeName,attributeValue:texts});
		specificationItems.push({attributeName:txCheck[1].attributeName,attributeValue:txCheckNC});
		console.log(specificationItems)

		$("[name='network']").each(function () {
			$(this).val(specificationItems[0].attributeValue[0]);
		});
		$("[name='memorys']").each(function () {
			$(this).val(specificationItems[1].attributeValue[0]);
		});
		$("[name='status']:checked").each(function () {
			$(this).val(1);
		});
		$("[name='isDefault']:checked").each(function () {
			$(this).val(1);
		});
		/*将网络-机身内存-价格-库存-是否启用-是否默认存入集合*/
		var table = $("#tables");
		var trs = table.find("tr");
		var list = [];
		for (var i = 1; i < trs.length; i++) {
			var tds = $(trs[i]).find("td");
			var val1 = $(tds[0]).find("input").val();
			var val2 = $(tds[1]).find("input").val();
			var val3 = $(tds[2]).find("input").val();
			var val4 = $(tds[3]).find("input").val();
			var val5 = $(tds[4]).find("input").val();
			var val6 = $(tds[5]).find("input").val();
			list.push({network:val1,memorys:val2,price:val3,num:val4,status:val5,isDefault:val6});
		}
		console.log(JSON.stringify(list))
	}
	function addGoodsAndDesc() {
		/*实例化编辑器对象*/
		editor.sync();
		/*获取值*/
		// 商品介绍
		var content = $("textarea[name='content']").val();
		//一级类目
		var category1Id = $("[name='category1Id']").val();
		//二级类目
		var category2Id = $("[name='category2Id']").val();
		//三级类目
		var category3Id = $("[name='category3Id']").val();
		// 商品名称
		var goodsName = $("[name='goodsName']").val();
		// 品牌
		var brandId = $("[name='brandId']").val();
		// 副标题
		var caption = $("[name='caption']").val();
		// 价格
		var price = $("[name='price']").val();
		// 包装列表
		var packageList = $("[name='packageList']").val();
		// 售后服务
		var saleService = $("[name='saleService']").val();
		//图片url
		var imgItemUrls = [];
		$("img[name='imgItemUrl']").each(function () {
			var Item = {url:$(this).attr("src")};
			imgItemUrls.push(Item);
		});
		/*图片颜色*/
		var imgItemColors = [];
		$("[name='imgItemColor']").each(function () {
			var Item = {color:$(this).text()};
			imgItemColors.push(Item);
		});
		var smallImg = [];
		for (var p = 0; p < imgItemUrls.length; p++) {
			var Item = {url:imgItemUrls[p].url,color:imgItemColors[p].color}
			smallImg.push(Item);
		}
		var smallPic = JSON.stringify(smallImg);
		console.log(smallPic);
		//temsCAI_Text
		var temsCAI_Text = [];
		$("[name='temsCAI_Text']").each(function () {
			var Item = {text:$(this).text()};
			temsCAI_Text.push(Item);
		});
		// temsCAI_Value
		var temsCAI_Value = [];
		$("[name='temsCAI_Value']").each(function () {
			var Item = {value:$(this).val()};
			temsCAI_Value.push(Item);
		});
		/*扩展属性,自定义属性*/
		var temsCAI = [];
		for (var t = 0; t < temsCAI_Text.length; t++) {
			temsCAI.push({text:temsCAI_Text[t].text,value:temsCAI_Value[t].value});
		}
		/*获取选中的规格*/
		var txCheck = [];
		$("[name='txCheck']").each(function () {
			var Item = {attributeName:$(this).text()};
			txCheck.push(Item);
		});
		var txCheckNC = [];
		$("[name='sCheck1']:checked").each(function () {
			txCheckNC.push($(this).val());
		});
		var texts = [];
		$("[name='sCheck2']:checked").each(function () {
			texts.push($(this).val());
		});
		var specificationItems = [];
		specificationItems.push({attributeName:txCheck[0].attributeName,attributeValue:texts});
		specificationItems.push({attributeName:txCheck[1].attributeName,attributeValue:txCheckNC});

		$("[name='network']").each(function () {
			$(this).val(specificationItems[0].attributeValue[0]);
		});
		$("[name='memorys']").each(function () {
			$(this).val(specificationItems[1].attributeValue[0]);
		});
		$("[name='status']:checked").each(function () {
			$(this).val(1);
		});
		$("[name='isDefault']:checked").each(function () {
			$(this).val(1);
		});
		/*将网络-机身内存-价格-库存-是否启用-是否默认存入集合*/
		var table = $("#tables");
		var trs = table.find("tr");
		var list = [];
		for (var i = 1; i < trs.length; i++) {
			var tds = $(trs[i]).find("td");
			var val1 = $(tds[0]).find("input").val();
			var val2 = $(tds[1]).find("input").val();
			var val3 = $(tds[2]).find("input").val();
			var val4 = $(tds[3]).find("input").val();
			var val5 = $(tds[4]).find("input").val();
			var val6 = $(tds[5]).find("input").val();
			list.push({network:val1,memorys:val2,price:val3,num:val4,status:val5,isDefault:val6});
		}
		console.log(JSON.stringify(list))

		$.ajax({
			url: "/goods/addGoodsAndDesc",
			dataType: "json",
			type: "post",
			data: {
				content:content,
				category1Id:category1Id,
				category2Id:category2Id,
				category3Id:category3Id,
				goodsName:goodsName,
				brandId:brandId,
				caption:caption,
				price:price,
				packageList:packageList,
				saleService:saleService,
				smallPic:smallPic,
				customAttributeItems:JSON.stringify(temsCAI),
				specificationItems:JSON.stringify(specificationItems),
				listItem:JSON.stringify(list)
			},
			async:false,
			success:function (result) {
				if (result.code == 10000){
					alert(result.message)
				}else if(result.code == 9999){
					alert(result.message)
				}
			},error:function (result) {
				alert(result.message)
			}
		})
	}
</script>
</body>
<script type="text/javascript">
	$(function () {
		findItem(0,$("#shopItemOne"));
	})
	function findItem(id,shopItem) {
		$.ajax({
			url: "/goods/getItemCatById",
			dataType: "json",
			type: "post",
			data: {parentId:id},
			async:false,
			success:function (result) {
				var list = result.data;
				var html = '';
				if (result.code == 10000){
					html += '<option value="-1">--请选择--</option>';
					for (var i = 0; i < list.length; i++) {
						html += '<option value="'+list[i].id+'">'+list[i].name+'</option>';
					}
					shopItem.html(html);
				}
			},error:function (result) {
				alert("错误!")
			}
		})
	}
	function shopItemOne(id) {
		findItem(id,$("#shopItemTow"));
		if (id == -1){
			$("#shopItemTow").html("");
		}
		$("#shopType").html("");
		$("#typeID").text("");
		$("#shopItemThree").html("");
	}
	function shopItemTow(id) {
		findItem(id,$("#shopItemThree"));
		$("#shopType").html("");
		$("#typeID").text("");
	}
	function shopItemThree(id) {
		$.ajax({
			url: "/goods/getItemCatByIdOnType",
			dataType: "json",
			type: "post",
			data: {typeId:id},
			async:false,
			success:function (result) {
				console.log(result);
				$("#typeID").text(result.data.id);
				var brandIds = result.data.brandIds;
				/*品牌*/
				var list = JSON.parse(brandIds);
				var html = '';
				/*规格*/
				var specIds = result.data.specIds;
				var specList = JSON.parse(specIds);
				var specHtml = '';
				/*custom_attribute_items扩展属性*/
				var htmlCAI = '';
				if (result.code == 10000){
					html += '<option value="-1">--请选择--</option>';
					for (var i = 0; i < list.length; i++) {
						html += '<option value="'+list[i].id+'">'+list[i].text+'</option>';
					}
					$("#shopType").html(html);
					for (var j = 0; j < specList.length; j++) {
						console.log(specList[j].text);
						console.log(specList[j].id);
						htmlCAI += '<div class="row data-type"><div>';
						htmlCAI += '<div class="col-md-2 title" name="temsCAI_Text">'+specList[j].text+'</div>';
						htmlCAI += '<div class="col-md-10 data">';
						htmlCAI += '<input name="temsCAI_Value" class="form-control" placeholder="'+specList[j].text+'">';
						htmlCAI += '</div></div><div>';
					}
					specHtml += '<input type="checkbox" id="specCheck" onclick="specOption1(this,27,&quot;网络&quot;)" value="'+27+'"><a id="specIdList">网络</a>';
					specHtml += '<input type="checkbox" id="specCheck" onclick="specOption2(this,32,&quot;机身内存&quot;)" value="'+32+'"><a id="specIdList">机身内存</a>';
					$("#specIds").html(specHtml);
					$("#customAttribute").html(htmlCAI);
				}else if (result.code == 9999){
					alert(result.message)
				}
			},error:function (result) {
				alert("错误!")
			}
		})
	}
	$('#myFile').fileinput({
		language: 'zh',//汉化
		uploadUrl:"/fileController/uploadFile",//上传地址
		browseClass: 'btn btn-primary',
		allowedFileExtensions:['jpg','png','gif','txt','pdf','xls','xlsx','ico'], //限制文件上传类型
		maxFileSize:2048,//设置文件上传大小 单位kb
		maxFileCount:1,//最大上传数量
		showUploadedThumbs:false,
		enctype: "multipart/form-data"
	});
	//上传成功回调
	$('#myFile').on('fileuploaded',function(event, data, previewId, index){
		console.log(data);
		if(data.response != null){
			$("[name='goodImage']").val(data.response.data);//abc.jpg  + "," + bcd.jpg
		}
	})
	/*添加图片标签*/
	function addMigContent() {
		var html = '';
		html += '<tr><td><a name="imgItemColor">'+$("#imgColor").val()+'</a></td>';
		html += '<td><img name="imgItemUrl" alt="" src="'+$("[name='goodImage']").val()+'" width="100px" height="100px"></td>';
		html += '<td> <button type="button" onclick="dele(this)" class="btn btn-default" title="删除" ><i class="fa fa-trash-o"></i> 删除</button></td>';
		html += '</tr>';
		$("#imgContent").append(html);
		$('#uploadModal input').val('')
	}
	/*删除图片标签*/
	function dele(obj){
		var otr = obj.parentNode.parentNode;
		var tab =  otr.parentNode; //自己的父节点 就是table
		tab.removeChild(otr);
	}
	/*规格选择时触发*/
	function specOption1(obj,vl,tx) {
		if ($(obj).is(":checked")){
			/*选择事件*/
			/*通过规格id查找对应规格*/
			$.ajax({
				url: "/goods/getSpecificationeBySpecId",
				dataType: "json",
				type: "post",
				data: {
					id:vl,
					text:tx
				},
				async:false,
				success:function (result) {
					console.log(result)
					if (result.code == 10000){
						var specNameHtml = '';
						var optionList = result.data.list;
						console.log(optionList)
						specNameHtml += '<div name="specificationName">';
						specNameHtml += '<div name="txCheck" class="col-md-2 title">'+tx+'</div>';
						specNameHtml += '<div class="col-md-10 data">';
						for (var i = 0; i < optionList.length; i++) {
							specNameHtml += '<span id="spanCheck"><input name="sCheck2"  type="checkbox" value="'+optionList[i].optionName+'">'+optionList[i].optionName+'</span>';
						}
						specNameHtml += '</div></div></div>';
						$("#specificationNames").append(specNameHtml);
					}else if (result.code == 9999){
						alert(1)
					}
				},error:function (result) {
					alert(result.message)
				}
			})
		}else {
			/*取消选中事件*/
			$("#specificationNames").html("");
			$("#specCheck").removeAttr("checked");
		}
	}
	function specOption2(obj,vl,tx) {
		if ($(obj).is(":checked")){
			/*选择事件*/
			/*通过规格id查找对应规格*/
			$.ajax({
				url: "/goods/getSpecificationeBySpecId",
				dataType: "json",
				type: "post",
				data: {
					id:vl,
					text:tx
				},
				async:false,
				success:function (result) {
					console.log(result)
					if (result.code == 10000){
						var specNameHtml = '';
						var optionList = result.data.list;
						console.log(optionList)
						specNameHtml += '<div name="specificationName">';
						specNameHtml += '<div name="txCheck" class="col-md-2 title">'+tx+'</div>';
						specNameHtml += '<div class="col-md-10 data">';
						for (var i = 0; i < optionList.length; i++) {
							specNameHtml += '<span id="spanCheck"><input name="sCheck1" type="checkbox" value="'+optionList[i].optionName+'">'+optionList[i].optionName+'</span>';
						}
						specNameHtml += '</div></div></div>';
						$("#specificationNames").append(specNameHtml);
					}else if (result.code == 9999){
						alert(1)
					}
				},error:function (result) {
					alert(result.message)
				}
			})
		}else {
			/*取消选中事件*/
			$("#specificationNames").html("");
			$("#specCheck").removeAttr("checked");
		}
	}

</script>
</html>